package com.bdcom.nms.NmsCollect.pojo;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.opengoss.snmphibernate.api.SmiType;
import org.opengoss.snmphibernate.api.annotation.MibIndex;
import org.opengoss.snmphibernate.api.annotation.MibObjectType;
import org.opengoss.snmphibernate.api.annotation.MibObjectType.Access;
import org.opengoss.snmphibernate.api.annotation.MibTable;

import com.bdcom.nms.NmsCollect.toolkit.MibToolkit;
@Entity
@Table(name="ifentry")
@SuppressWarnings("serial") //$NON-NLS-1$
@MibTable
public class IfEntry implements Serializable {
	
	@Id
	@GenericGenerator(name="uuid",strategy="org.hibernate.id.UUIDHexGenerator")
	@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
	private String  uuid;
	
	private String ip;
	
	private Long collectTime;

	@MibIndex(no = 0, length = 1)
	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.1", smiType = SmiType.INTEGER32, access = Access.READ) //$NON-NLS-1$
	private int ifIndex;
 
	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.2", smiType = SmiType.DISPLAY_STRING, access = Access.READ) //$NON-NLS-1$
	private String ifDescr;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.3", smiType = SmiType.INTEGER32, access = Access.READ) //$NON-NLS-1$
	private int ifType;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.4", smiType = SmiType.INTEGER32, access = Access.READ) //$NON-NLS-1$
	private int ifMtu;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.5", smiType = SmiType.GAUGE32, access = Access.READ) //$NON-NLS-1$
	private long ifSpeed;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.6", smiType = SmiType.OCTET_STRING, access = Access.READ) //$NON-NLS-1$
	private transient byte[] PhysAddress;
	
	private  String  ifPhysAddress;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.7", smiType = SmiType.INTEGER32, access = Access.READ) //$NON-NLS-1$
	private int ifAdminStatus;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.8", smiType = SmiType.INTEGER32, access = Access.READ) //$NON-NLS-1$
	private int ifOperStatus;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.9", smiType = SmiType.TIMETICKS, access = Access.READ) //$NON-NLS-1$
	private long ifLastChange;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.10", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifInOctets;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.11", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifInUcastPkts;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.12", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifInNUcastPkts;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.13", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifInDiscards;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.14", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifInErrors;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.15", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifInUnknownProtos;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.16", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifOutOctets;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.17", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifOutUcastPkts;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.18", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifOutNUcastPkts;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.19", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifOutDiscards;

	@MibObjectType(oid = "1.3.6.1.2.1.2.2.1.20", smiType = SmiType.COUNTER32, access = Access.READ) //$NON-NLS-1$
	private long ifOutErrors;

	public IfEntry() {}
	
	public IfEntry(int index) {
		this.ifIndex = index;
	}
	


	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public boolean isLoopback() {
		return ifType == 24;
	}

	public int getIfAdminStatus() {
		return ifAdminStatus;
	}

	public void setIfAdminStatus(int ifAdminStatus) {
		this.ifAdminStatus = ifAdminStatus;
	}

	public String getIfDescr() {
		return ifDescr;
	}

	public void setIfDescr(String ifDescr) {
		this.ifDescr = ifDescr;
	}

	public int getIfIndex() {
		return ifIndex;
	}

	public void setIfIndex(int ifIndex) {
		this.ifIndex = ifIndex;
	}

	public long getIfInDiscards() {
		return ifInDiscards;
	}

	public void setIfInDiscards(long ifInDiscards) {
		this.ifInDiscards = ifInDiscards;
	}

	public long getIfInErrors() {
		return ifInErrors;
	}

	public void setIfInErrors(long ifInErrors) {
		this.ifInErrors = ifInErrors;
	}

	public long getIfInNUcastPkts() {
		return ifInNUcastPkts;
	}

	public void setIfInNUcastPkts(long ifInNUcastPkts) {
		this.ifInNUcastPkts = ifInNUcastPkts;
	}

	public long getIfInOctets() {
		return ifInOctets;
	}

	public void setIfInOctets(long ifInOctets) {
		this.ifInOctets = ifInOctets;
	}

	public long getIfInUcastPkts() {
		return ifInUcastPkts;
	}

	public void setIfInUcastPkts(long ifInUcastPkts) {
		this.ifInUcastPkts = ifInUcastPkts;
	}

	public long getIfInUnknownProtos() {
		return ifInUnknownProtos;
	}

	public void setIfInUnknownProtos(long ifInUnknownProtos) {
		this.ifInUnknownProtos = ifInUnknownProtos;
	}

	public long getIfLastChange() {
		return ifLastChange;
	}

	public void setIfLastChange(long ifLastChange) {
		this.ifLastChange = ifLastChange;
	}

	public int getIfMtu() {
		return ifMtu;
	}

	public void setIfMtu(int ifMtu) {
		this.ifMtu = ifMtu;
	}

	public int getIfOperStatus() {
		return ifOperStatus;
	}

	public void setIfOperStatus(int ifOperStatus) {
		this.ifOperStatus = ifOperStatus;
	}

	public long getIfOutDiscards() {
		return ifOutDiscards;
	}

	public void setIfOutDiscards(long ifOutDiscards) {
		this.ifOutDiscards = ifOutDiscards;
	}

	public long getIfOutErrors() {
		return ifOutErrors;
	}

	public void setIfOutErrors(long ifOutErrors) {
		this.ifOutErrors = ifOutErrors;
	}

	public long getIfOutNUcastPkts() {
		return ifOutNUcastPkts;
	}

	public void setIfOutNUcastPkts(long ifOutNUcastPkts) {
		this.ifOutNUcastPkts = ifOutNUcastPkts;
	}

	public long getIfOutOctets() {
		return ifOutOctets;
	}

	public void setIfOutOctets(long ifOutOctets) {
		this.ifOutOctets = ifOutOctets;
	}

	public long getIfOutUcastPkts() {
		return ifOutUcastPkts;
	}

	public void setIfOutUcastPkts(long ifOutUcastPkts) {
		this.ifOutUcastPkts = ifOutUcastPkts;
	}

	public byte[] getPhysAddress() {
		return PhysAddress;
	}

	public void setPhysAddress(byte[] physAddress) {
		PhysAddress = physAddress;
	}

	public String getIfPhysAddress() {
		return MibToolkit.getPhysAddr(PhysAddress);
	}

	public void setIfPhysAddress() {
		this.ifPhysAddress = getIfPhysAddress();
	}

	public long getIfSpeed() {
		return ifSpeed;
	}

	public void setIfSpeed(long ifSpeed) {
		this.ifSpeed = ifSpeed;
	}

	public int getIfType() {
		return ifType;
	}

	public void setIfType(int ifType) {
		this.ifType = ifType;
	}
	
	

	public Long getCollectTime() {
		return collectTime;
	}

	public void setCollectTime(Long collectTime) {
		this.collectTime = collectTime;
	}

	@Override
	public String toString() {
		return "IfEntry [uuid=" + uuid + ", ip=" + ip + ", collectTime=" + collectTime + ", ifIndex=" + ifIndex
				+ ", ifDescr=" + ifDescr + ", ifType=" + ifType + ", ifMtu=" + ifMtu + ", ifSpeed=" + ifSpeed
				+ ", ifPhysAddress=" + ifPhysAddress + ", ifAdminStatus=" + ifAdminStatus + ", ifOperStatus="
				+ ifOperStatus + ", ifLastChange=" + ifLastChange + ", ifInOctets=" + ifInOctets + ", ifInUcastPkts="
				+ ifInUcastPkts + ", ifInNUcastPkts=" + ifInNUcastPkts + ", ifInDiscards=" + ifInDiscards
				+ ", ifInErrors=" + ifInErrors + ", ifInUnknownProtos=" + ifInUnknownProtos + ", ifOutOctets="
				+ ifOutOctets + ", ifOutUcastPkts=" + ifOutUcastPkts + ", ifOutNUcastPkts=" + ifOutNUcastPkts
				+ ", ifOutDiscards=" + ifOutDiscards + ", ifOutErrors=" + ifOutErrors + "]";
	}

	

	
}
